home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c / pro22 / cbsetrcu.c < prev    next >
Text File  |  1990-06-20  |  2KB  |  87 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbsetrcu.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8.  
  9. /* library headers */
  10. #include <blkio.h>
  11. #include <lseq.h>
  12.  
  13. /* local headers */
  14. #include "cbase_.h"
  15.  
  16. /*man---------------------------------------------------------------------------
  17. NAME
  18.      cbsetrcur - set cbase record cursor
  19.  
  20. SYNOPSIS
  21.      #include <cbase.h>
  22.  
  23.      int cbsetrcur(cbp, cbrposp)
  24.      cbase_t *cbp;
  25.      const cbrpos_t *cbrposp;
  26.  
  27. DESCRIPTION
  28.      The cbsetrcur function sets the position of the record cursor of
  29.      cbase cbp to the value pointed to by cbposp.  If cbrposp is the
  30.      NULL pointer, the record cursor is set to null.
  31.  
  32.      cbsetrcur will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       cbp is not a valid cbase pointer.
  35.      [CBELOCK]      cbp is not locked.
  36.      [CBENOPEN]     cbp is not open.
  37.  
  38. SEE ALSO
  39.      cbgetrcur, cbrcursor, cbsetkcur.
  40.  
  41. DIAGNOSTICS
  42.      Upon successful completion, a value of 0 is returned.  Otherwise,
  43.      a value of -1 is returned, and errno set to indicate the error.
  44.  
  45. ------------------------------------------------------------------------------*/
  46. int cbsetrcur(cbp, cbrposp)
  47. cbase_t *cbp;
  48. const cbrpos_t *cbrposp;
  49. {
  50.     lspos_t    lspos    = NIL;
  51.  
  52.     /* validate arguments */
  53.     if (!cb_valid(cbp)) {
  54.         errno = EINVAL;
  55.         return -1;
  56.     }
  57.  
  58.     /* check if not open */
  59.     if (!(cbp->flags & CBOPEN)) {
  60.         errno = CBENOPEN;
  61.         return -1;
  62.     }
  63.  
  64.     /* check if not locked */
  65.     if (!(cbp->flags & CBLOCKS)) {
  66.         errno = CBELOCK;
  67.         return -1;
  68.     }
  69.  
  70.     /* set record cursor position */
  71.     if (cbrposp == NULL) {
  72.         if (lssetcur(cbp->lsp, NULL) == -1) {
  73.             CBEPRINT;
  74.             return -1;
  75.         }
  76.     } else {
  77.         lspos = *cbrposp;
  78.         if (lssetcur(cbp->lsp, &lspos) == -1) {
  79.             CBEPRINT;
  80.             return -1;
  81.         }
  82.     }
  83.  
  84.     errno = 0;
  85.     return 0;
  86. }
  87.